package com.reporting.yb.module.system.dal.mysql.reportingfile;

import com.reporting.yb.framework.common.pojo.PageResult;
import com.reporting.yb.framework.mybatis.core.mapper.BaseMapperX;
import com.reporting.yb.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.reporting.yb.module.system.controller.admin.reportingfile.vo.ReportingFilePageReqVO;
import com.reporting.yb.module.system.dal.dataobject.reportingfile.ReportingFileDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 投诉文件 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ReportingFileMapper extends BaseMapperX<ReportingFileDO> {

    default PageResult<ReportingFileDO> selectPage(ReportingFilePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReportingFileDO>()
                .eqIfPresent(ReportingFileDO::getReportingId, reqVO.getReportingId())
                .eqIfPresent(ReportingFileDO::getFile, reqVO.getFile())
                .eqIfPresent(ReportingFileDO::getCreator, reqVO.getCreator())
                .betweenIfPresent(ReportingFileDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(ReportingFileDO::getUpdater, reqVO.getUpdater())
                .orderByDesc(ReportingFileDO::getId));
    }
    default List<ReportingFileDO> selectListByReportingId(String reportingId) {
        return selectList(ReportingFileDO::getReportingId, reportingId);
    }

    default int deleteByReportingId(String reportingId) {
        return delete(ReportingFileDO::getReportingId, reportingId);
    }
}